//
//  LXDIsSingerViewController.m
//  BLDMusics
//
//  Created by lxd on 16/4/4.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "LXDIsSingerViewController.h"

@interface LXDIsSingerViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView*tableView;
@property (nonatomic, retain) NSMutableArray *modelArr;

@end

@implementation LXDIsSingerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createTableView];
    [self dataHandle];
}

- (void)createTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH - 64 - 60) style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[LXDIsSingerTableViewCell class] forCellReuseIdentifier:@"cell"];
}


#pragma mark - 协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _modelArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LXDIsSingerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    LXDIsSingerModel *model = _modelArr[indexPath.row];
    cell.model = model;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 170;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      LXDIsSingerModel *model = _modelArr[indexPath.row];
    WEBViewController *vc = [[WEBViewController alloc] init];
    vc.url = model.actionUrl;
    [self.navigationController pushViewController:vc animated:YES];
}


- (void)dataHandle {
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [APPTools GETWithURL:@"http://api.dongting.com/misc/musiczone/new?" par:nil success:^(id responseObject) {
        
        self.modelArr = [LXDIsSingerModel modelHandleWithArray:responseObject[@"data"]];
        [hud removeFromSuperview];
        [_tableView reloadData];
        
    } filed:^(NSError *error) {
        
    }];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
